﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using BLToolkit.Data;
using BLToolkit.DataAccess;
using BLToolkit.Mapping;
using Enities;
using BLL.Repository;

namespace BLL
{
    public class LuuTraTaiLieu:ITraTaiLieu
    {
        
        //lay danh sach tra tai lieu
        public DataTable LaydanhsachTTL()
        {
            using (DbManager db = new DbManager())
            {
                DataTable table = db.SetSpCommand("[LayTatCa]").ExecuteDataTable();
                return table;

            }
        }
        public void CapNhatTra(TraTaiLieu tratl)
        {
            using (DbManager db = new DbManager())
            {
                db.SetSpCommand("[CapNhatTraTaiLieu]", tratl.MaDocGia, tratl.MaTaiLieu, tratl.NgayMuon, tratl.NgayThucTra, tratl.SoLuong).ExecuteNonQuery();
            }
        }
        // them thong tin tra
        public void ThemTra(TraTaiLieu tratl)
        {
            using (DbManager db = new DbManager())
            {
                db.SetSpCommand("[ThemTraTL]", tratl.MaDocGia, tratl.MaTaiLieu, tratl.NgayMuon, tratl.NgayThucTra, tratl.SoLuong).ExecuteNonQuery();
            }
        }

        // Trả Tai liệu
        public void XoaTraTL(int MaDocGia)
        {
            using (DbManager db = new DbManager())
            {
                db.SetSpCommand("[XoaTraTaiLieu]", MaDocGia).ExecuteNonQuery();
            }
        }

        // tìm 
        public DataTable TimTraTL( int MaDocGia)
        {
            using (DbManager db = new DbManager())
            {
                DataTable table = db.SetSpCommand("[TimTraTL]", MaDocGia).ExecuteDataTable();
                return table;

            }
        }
 

    }
}
